-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Add Actor method use_state
#738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Let's please wait until the implementation is clarified in #735. |
vdusek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new use_state method to the Actor class, enabling users to easily create and manage state values that are automatically persisted to key-value stores. The state is persisted periodically (based on PERSIST_STATE_INTERVAL_MILLIS) and also when the Actor exits.
Changes:
- Added
Actor.use_state()method for managing persistent state - Implemented automatic state persistence on Actor exit via
_save_actor_state() - Added comprehensive unit tests covering default and custom configurations
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/apify/_actor.py | Implements the use_state method, adds state store tracking, and integrates state persistence into Actor lifecycle |
| tests/unit/actor/test_actor_key_value_store.py | Adds unit tests for the new use_state functionality with various scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
quite good comments from copilot 🙂 |
vdusek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for resolving those comments from Copilot, LGTM from my side, let's wait for @Pijukatel and merge it.
Description
Add
Actormethoduse_state. Allows the user to save data and states in kvs with periodic persistence.Issues
Closes: #735
Testing
Added unit tests